package com.xii.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.xii.constant.MessageConstant;
import com.xii.entity.Result;
import com.xii.service.OrderService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@RequestMapping("/order")
public class OrderController {

    @Reference
    private OrderService orderService;

    @RequestMapping("/submit")
    @ResponseBody
    public Result submit(@RequestBody Map map){
        return orderService.submit(map);
    }

    @RequestMapping("/findById")
    @ResponseBody
    public Result findById(Integer id){
        try {
            Map map = orderService.findById(id);
            //查询预约信息成功
            return new Result(true, MessageConstant.QUERY_ORDER_SUCCESS,map);
        } catch (Exception e) {
            e.printStackTrace();
            //查询预约信息失败
            return new Result(false,MessageConstant.QUERY_ORDER_FAIL);
        }
    }

}
